package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.DingDUser;
import com.ruoyi.system.mapper.DingDUserMapper;
import com.ruoyi.system.service.DingDUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DingDUserServiceImpl implements DingDUserService {
    @Autowired
    private DingDUserMapper dingDUserMapper;

    @Override
    public LoginBody rylogin() {
        LoginBody loginBody = new LoginBody();
        loginBody.setUsername("admin");
        loginBody.setPassword("admin123");
        String uuid = IdUtils.simpleUUID();//若依系统的自动获取uuid
        System.out.println("uuid是："+uuid);
        loginBody.setUuid(uuid);
        return loginBody;
    }

    @Override
    public List<DingDUser> querDDUser() {

        List<DingDUser>   ddUsersList =  dingDUserMapper.querDDUser();
        return ddUsersList;
    }

    @Override
    public String querDDUserNumber(String userName,String DDPassword) {
        if(dingDUserMapper.querDDUserNumber(userName) == null){
            return "账号或密码错误";
        }
        String password=  dingDUserMapper.querDDUserNumber(userName).getUserPassword();
        if(DDPassword.equals(password)){
            return "true";
        }
        return "账号或密码错误";
    }

    @Override
    public String querAdmin(String userName) {
        if(dingDUserMapper.querAddmin(userName) == null){
            return "信息错误";
        }
        int adminInfo =  dingDUserMapper.querAddmin(userName).getUserAdminInfo();
        if(adminInfo == 1){
            return "主管理员";
        }if(adminInfo == 2){
            return "普通员工";
        }
        return "权限信息错误";
    }
}